package com.joy.vod.controller;

import com.joy.commonutils.R;
import com.joy.vod.service.VodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author 焦恩越
 * @create 2021-12-04-16:39
 */
@RestController
@CrossOrigin
@RequestMapping("/eduvod/video")
public class VodController {
    @Autowired
    private VodService vodService;

    //上传视频到阿里云
    @PostMapping("/uploadAlyiVideo")
    public R uploadAlyiVideo(MultipartFile file){
        //返回上传视频的id值
        String videoId = vodService.uploadVideoAly(file);
        return R.ok().data("videoId",videoId);
    }
    //根据视频id删除阿里云里面的视频
    @DeleteMapping("/removeAlyiVideo/{id}")
    public R removeAlyiVideo(@PathVariable String id){
        vodService.deleteVideoById(id);
        return R.ok();
    }
    //删除多个视频的方法
    //参数是多个id值
    @DeleteMapping("/deleteBatch")
    public R deleteBatch(@RequestParam("videoIdList") List videoIdList){
        vodService.removeAlyVideo(videoIdList);
        return R.ok();
    }
}
